import Vue from 'vue';

import Vuex from 'vuex';
Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		count: 0,
		orderList: {},
		orderId: '',
		carList: [],
	},
	mutations: {
		increment(state) {
			state.count++
		},
		addOrder(state, payload) {
			// state.orderList = payload.datas
			state.orderList = payload
			console.log(payload)
		},
		addOrderId(state, payload) {
			console.log(payload);
			state.orderId = payload
		},
		addCarList(state, payload) {
			console.log(payload, '购物车数据')
			state.carList = payload
		}
	},
	getters: {
		totalPrice(state) {
			return (state.orderList.price * state.orderList.count)
		}
	}
})

export default store
